<template>
    <div>
        <r-form ref="myForm" :rules="rules" :form="form" :items="items" :save="save">
        </r-form>
        <a target="_blank" :href="form.attach">附件下载</a>
    </div>
</template>

<script>
    import RForm from "@/components/RForm";
    import {studentInfo,updateSelective} from '@/api/student'
    import {dict_query} from '@/api/dict'
    export default {
        name: "StudentInfo",
        components:{RForm},
        data(){
            return{
                form:{
                    id:'',
                    result:'',
                    company:'',
                    jobDate:'',
                    post:'',
                    attach:''
                },
                rules:{
                    result:[{required:true,message:'必填项不能为空'}],
                },
                items:[
                    {type:'select',label:'就业结果',prop:'result',name:'result',placeholder:'请输入就业结果'},
                    {type:'date',label:'就业日期',prop:'jobDate',name:'jobDate',placeholder:'就业日期'},
                    {type:'text',label:'就业公司',prop:'company',name:'company',placeholder:'就业公司'},
                    {type:'text',label:'职位',prop:'post',name:'post',placeholder:'职位'},
                    {type:'file',label:'合同附件',prop:'attach',name:'attach',placeholder:'合同附件'}
                ]
            }
        },

        mounted() {
            this.getDictList1(8);
            this.getInfo();
        },

        methods:{
            getDictList1(typeId){
                dict_query({typeId:typeId}).then(res=>{
                    let arr = [];
                    res.data.forEach(item=>{
                        let p = {value:item.dictKey,label:item.dictVal};
                        arr.push(p);
                    });
                    this.items.forEach(item=>{
                        if(item.type=='select' && item.name == 'result'){
                            item.options= arr;
                        }
                    })
                })
            },


            getInfo(){
                studentInfo().then(res=>{
                    this.form = res.data;
                    console.log(this.form)
                })
            },
            save(){
                let flag = this.$refs['myForm'].validateForm();
                if(flag){
                    let param = this.form;
                    updateSelective(param).then(res=>{
                        this.$message.success(res.msg);
                        this.param.close();
                        this.param.callback();
                    })
                }
            }
        }
    }
</script>

<style scoped>

</style>